<template xmlns:v-clipboard="http://www.w3.org/1999/xhtml">
    <transition name="slide-right">
        <v-touch class="content content-editing" v-on:swiperight="">
            <div class="editing-title">
                <span class="editing-left mui-icon mui-icon-back" @click="backRoute()"></span>
                <span></span>
                <span class="editing-right" @click="save()">{{ $t('m.my.contact.edit.listTitle') }}</span>
            </div>
            <div class="editing-information">
                <div><span>{{ $t('m.my.contact.edit.prompt[0]') }}</span><input type="text" v-model="contact.title"></div>
                <div><span>{{ $t('m.my.contact.edit.prompt[1]') }}</span><input type="text" v-model="contact.tip"></div>
            </div>
            <div class="editing-content">
                <div class="operation">
                    <div>{{ $t('m.my.contact.edit.prompt[2]') }}</div>
                    <div  v-clipboard:copy="contact.address"
                          v-clipboard:success="doClipboard"
                          v-clipboard:error="">{{ $t('m.my.contact.edit.prompt[3]') }}</div>
                </div>
                <div>{{ contact.address }}</div>
            </div>
            <Success></Success>
            <Alert_little></Alert_little>
        </v-touch>
    </transition>
</template>
<script>
    /* eslint-disable */

    export default {
        name: "my_contact_edit",
        created() {
            this.getContact();
        },
        mounted() {
        },
        data() {
            return {
                contact: {
                    title: "",
                    tip: "",
                    address: ""
                },
            }
        },
        methods: {
            getContact: function () {
                let index = this.$route.query.id;
                let contactList = JSON.parse(localStorage.getItem('contract') ? localStorage.getItem('contract') : "[]");
                this.contact = contactList[Number(index)];
            },
            save: function () {
                let index = this.$route.query.id;
                let contactList = JSON.parse(localStorage.getItem('contract') ? localStorage.getItem('contract') : "[]");
                contactList[Number(index)] = this.contact;
                localStorage.setItem('contract', JSON.stringify(contactList));
                this.aSuccess({
                    show: true,
                    tip: this.$t('m.component.alert_shot.prompt1[1]')
                }).then(() => {
                    this.backRoute()
                });
            },
            doClipboard: function () {
                this.aAlert_little({
                    msg: this.$t('m.my.contact.edit.prompt[4]'),
                    top: "220px"
                })
            }
        }
    }
</script>
<style scoped>
    @import '../../../assets/css/editing.css';

    .content-contact-add {
        background: #ffffff;
    }

</style>